/**
 * @file STL_XML.hpp
 * @author Derek Liu (yjkhtddx@sina.com)
 * @brief 
 * @version 0.1
 * @date 2020-09-15
 * 
 * @copyright Copyright Sci-Tech Laboratories (c) 2020
 * 
 */

#ifndef ETL_XML_HPP
#define ETL_XML_HPP

#include <string>
#include "tinyxml.h"

namespace STL
{
    /**
     * @brief 
     *
     * TiXmlBase：整个TinyXML模型的基类。
     * TiXmlAttribute：对应于XML中的元素的属性。
     * TiXmlNode：对应于DOM结构中的节点。
     * TiXmlComment：对应于XML中的注释。
     * TiXmlDeclaration：对应于XML中的申明部分,即<？versiong="1.0" ?>。
     * TiXmlDocument：对应于XML的整个文档。
     * TiXmlElement：对应于XML的元素。
     * TiXmlText：对应于XML的文字部分。
     * TiXmlUnknown：对应于XML的未知部分。
     * TiXmlHandler：定义了针对XML的一些操作
     */
    class STL_XML
    {
    public:
        static void testXml(std::string xml);

    public:
        static TiXmlDocument *newPointer_ParseXmlString(std::string xml);
        static TiXmlElement *getRootElementFromDocument(TiXmlDocument *doc);
        static TiXmlDeclaration *getDeclarationfromDocument(TiXmlDocument *doc);
        // static TiXmlElement *newPointer_getRootElementFormXmlString(std::string xml);
        static std::string getStreamXmlString(TiXmlDocument *doc);
        static std::string getFormatXmlString(TiXmlDocument *doc);

    public:
        static void LinkEndChildWithClone(TiXmlNode *parent, TiXmlNode *child);
        static std::string getNodeText(TiXmlNode *node);
        static void setNodeText(TiXmlNode *node, std::string text);
        static std::string getValueWithoutXmlns(std::string value);

    public:
        static TiXmlElement *addObjectNode(TiXmlNode *target, std::string key);
        static TiXmlElement *addTextNode(TiXmlElement *target, std::string key, std::string value);
        static void setElementAttribute(TiXmlElement *target, std::string key, std::string value);
        // public:
        //     TiXmlElement *insert_child(TiXmlElement *root, const char *key, const std::string &value);
    public:
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2, std::string key3);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2, std::string key3, std::string key4);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2, std::string key3, std::string key4, std::string key5);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2, std::string key3, std::string key4, std::string key5, std::string key6);
        static TiXmlElement *getChildElement(TiXmlNode *parent, std::string key0, std::string key1, std::string key2, std::string key3, std::string key4, std::string key5, std::string key6, std::string key7);
        // private:
        // TiXmlDocument s_Doc;
    };
} // namespace STL

#endif /* ETL_XML_HPP */
